<template>
    <div>
        <van-field label="账号：" v-model="form.username"/>
        <van-field label="密码：" v-model="form.password"/>
        <van-button @click="denglu">登录</van-button>
    </div>
</template>

<script>
import maxios from '../http/axios'
export default {
    name: "login",
    data(){
    return{
      form:{}
      }
    },
    methods:{
      denglu(){
        maxios('/loginM','post',this.form).then(res=>{
          if(res.code==200){
            localStorage.setItem('uid',res.uid)
            localStorage.setItem('username',res.username)
            localStorage.setItem('is_admin',res.is_admin)
            localStorage.setItem('token',res.token)
            localStorage.setItem('url',JSON.stringify(res.url))
            alert(res.mes)
            this.$router.push('/com')
          }else {
            alert(res.mes)
          }
        })
      }
    }
}
</script>

<style scoped>

</style>